<link rel="stylesheet" type="text/css" href="/css/editproduct.css" />
<link rel="stylesheet" type="text/css" href="/css/tabLanguages.css" />
<script src="/js/admin/jquery/jquery-1.6.1.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="/js/ckeditor/ckeditor.js" language="javascript" ></script>
	<link rel="stylesheet" type="text/css" href="/js/admin/jquery/ui/themes/ui-lightness/jquery.ui.all.css" />
	<script src="/js/admin/jquery/ui/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
	<script src="/js/admin/jquery/ui/external/jquery.bgiframe-2.1.2.js" type="text/javascript"></script>
	<script src="/js/admin/jquery/tab.js" type="text/javascript"></script>
	<script src="/js/admin/jquery/superfish/js/superfish.js" type="text/javascript"></script>

				<div style="float:left;font-style: oblique;font-weight: bold;font-size: large;color:blue;"><?php echo $this->title;?></div>
				<div style="clear: both;"></div>
				<hr></hr>					
				<?php if($this->error == 1){?>
					<script type="text/javascript">
						window.parent.$.prettyPhoto.close();
						window.top.location.reload();
						window.parent.$.prettyPhoto.close();
					</script>
				<?php } if($this->error == 100){?><h4 style="color:red;margin-top: -15px;height: 10px;"><?php echo $this->textError100;?></h4><?php } else {?>
				<form id="form_edit_product" name="form_edit_product" enctype="multipart/form-data" action="/productdetail/clickchange?action=edit&id=<?php echo $_GET["id"];?>" method="post">
			<table cellspacing="5" cellpadding="2">
				<tr>
					<td><span style="font-weight: bold;"><?php echo $this->textProductName;?></span></td>
					<td><input type="text" value="<?php if(isset($this->new_product_name)) echo $this->new_product_name; else echo $this->ProductDetail['title'];?>" size="30" maxlength="30" id="product_name" name="product_name" class="content_input"/></td>
				</tr>
				<?php if(isset($this->error_title) && $this->error_title == 1){?><tr ><td></td><td><span style="color:red;height: 10px;"><?php echo $this->textError2;?></span></td></tr><?php }?>
				<?php if(isset($this->getAllLeafCate) && count($this->getAllLeafCate) > 0){?>
				<tr>
					<td><span style="font-weight: bold;"><?php echo $this->textCate;?></span></td>
					<td><select id="product_category" name="product_category" tabindex="0">
								<?php foreach ($this->getAllLeafCate as $category){?>
								<option <?php if(isset($this->new_product_category)){ if($this->new_product_category==$category["category_id"]){ ?>selected="selected"<?php } } else if(($this->ProductDetail['category_id']!=0)&&($this->ProductDetail['category_id'] == $category["category_id"])){?>selected="selected"<?php } ?> value="<?php echo $category["category_id"];?>"><?php echo $category["category_name"];?></option>
								<?php }?>
							 </select></td>
				</tr>
				<?php }?>
				<?php if(isset($this->error_cate) && $this->error_cate == 1){?><tr><td></td><td><span style="color:red;height: 10px;"><?php echo $this->textError3;?></span></td></tr><?php }?>

				<tr>
					<td><span style="font-weight: bold;"><?php echo $this->Price;?></span></td>
					<td><input id="product_price" name="product_price" value = "<?php if(isset($this->new_product_price)) echo $this->new_product_price; else echo $this->ProductDetail['price'];?>" /></td>
				</tr>
				<?php if(isset($this->error_price) && $this->error_price == 1){?><tr><td></td><td><span style="color:red;height: 10px;"><?php echo $this->textError7;?></span></td></tr><?php }?>
				<tr>
					<td><span style="font-weight: bold;"><?php echo $this->textImage;?></span></td>
					<td>
						<img src="<?php if(isset($this->new_product_avatar)) echo $this->new_product_avatar; else echo $this->ProductDetail['avatar'];?>" id="image_url" class="image" style ="width:150px;height:150px;" onclick="image_upload('product_avatar', 'image_url','1');" />
						<input type="hidden" id="product_avatar" name="product_avatar" value="<?php if(isset($this->new_product_avatar)) echo $this->new_product_avatar; else echo $this->ProductDetail['avatar'];?>" id="product_avatar" />
					</td>
				</tr>
				<tr>
					<td><span style="font-weight: bold;"><?php echo $this->RelateImage;?></span></td>
					<td>
							<?php $i= 2;?>
							<?php if(isset($this->AllImage)){?>
								<?php foreach ($this->AllImage as $product_image)
								{?>
									<img src="<?php echo $product_image['url']?>" id="image_related_<?php echo $i;?>" class="image" style ="width:80px;height:80px;" onclick="image_upload('image_related<?php echo $i;?>', 'image_related_<?php echo $i;?>','<?php echo $i;?>');" />
									<input type="hidden" name="relatedImageUpload[]" value="<?php echo $product_image['url']?>" id="image_related<?php echo $i;?>" />						
								<?php $i++;}?>
							<?php }?>
							<?php if($i<4){?>
								<?php while($i<=4){?>
									<img src="/images/noimage.jpg" id="image_related_<?php echo $i;?>" class="image" style ="width:80px;height:80px;" onclick="image_upload('image_related<?php echo $i;?>', 'image_related_<?php echo $i;?>','<?php echo $i;?>');" />
									<input type="hidden" name="relatedImageUpload[]" value="/images/noimage.jpg" id="image_related<?php echo $i;?>" />								
							<?php $i++;}}?>		
					</td>
				</tr>					
			</table>			
					
			<div id="content"></div>
			<div style="clear:both;"></div>
			<hr />
		<div id="languages" class="htabs">
        	<a tab="#language0" class="selected"><?php echo 'Default'; ?></a>
          <?php foreach ($this->languages as $language) { ?>
          <a tab="#language<?php echo $language['language_id']; ?>"><?php echo $language['name']; ?></a>
		  <?php } ?>
        </div>
        <div id="language0">
			<div class="content_row">
				<?php if(isset($this->error_desc['Default'][1])){?><h4 style="margin-left:0px;color:red;margin-top: 0px;height: 10px;"><?php echo $this->error_desc['Default'][1];?></h4><?php }?>
				<div class="content_row_l"><p style="font-size: 16px;font-weight: bold;"><?php echo $this->ShortDes;?></p></div>				
					<div class="content_row_r">
						<textarea name="product_short_description[Default]" style="width:500px"><?php echo $this->short_des['Default'];?></textarea>

					</div>

			</div>
			<div class="content_row">
				<?php if(isset($this->error_desc['Default'][0])){?><h4 style="color:red;margin-top: 0px;height: 10px;"><?php echo $this->error_desc['Default'][0];?></h4><?php }?>
				<div class="content_row_l"><p style="font-size: 16px;font-weight: bold;"><?php echo $this->Productinfo?></p></div>
					<div class="content_row_r">
						<textarea name="product_description[Default]" class="ckeditor" style="visibility: hidden; display: none;"><?php echo $this->description['Default'];?></textarea>
					</div>
			</div>
		</div>        
        <?php foreach ($this->languages as $language) { ?>
        <div id="language<?php echo $language['language_id']; ?>">
			<div class="content_row">
				<?php if(isset($this->error_desc[$language['name']][1])){?><h4 style="color:red;margin-top: 0px;height: 10px;"><?php echo $this->error_desc[$language['name']][1];?></h4><?php }?>			
				<div class="content_row_l"><p style="font-size: 16px;font-weight: bold;"><?php echo $this->ShortDes;?></p></div>
					<div class="content_row_r">
						<textarea name="product_short_description[<?php echo $language['name'];?>]" style="width:500px"><?php if(isset($this->short_des[$language['name']])){ echo $this->short_des[$language['name']];}?></textarea>
					</div>
			</div>
			<div class="content_row">
				<?php if(isset($this->error_desc[$language['name']][0])){?><h4 style="color:red;margin-top: 0px;height: 10px;"><?php echo $this->error_desc[$language['name']][0];?></h4><?php }?>
				<div class="content_row_l"><p style="font-size: 16px;font-weight: bold;"><?php echo $this->Productinfo?></p></div>
					<div class="content_row_r">
						<textarea name="product_description[<?php echo $language['name'];?>]" class="ckeditor" style="visibility: hidden; display: none;"><?php if(isset($this->description[$language['name']])){ echo $this->description[$language['name']];}?></textarea>
					</div>
			</div>
		</div>
		<?php }?>
		<div style="clear:both;"></div><br />					
		<div class="content_btn" style="width:100%;margin-bottom:5px;">
			<div class="submit">
				<input  class="edit_submit" type="submit" name="submit" value="<?php echo $this->Save;?>" />
			</div>
		</div>
				
		</form>
				

			<?php }?>
<script type="text/javascript"><!--
	function image_upload(field, preview, id) {
	$('#dialog').remove();
	$('#content').prepend('<div id="dialog" style="padding: 3px 0px 0px 0px;"><iframe src="/admin/filemanager?field=' + encodeURIComponent(field) + '" style="padding:0; margin: 0; display: block; width: 100%; height: 100%;" frameborder="no" scrolling="auto"></iframe></div>');
	$('#dialog').dialog({

							title: 'Images Manager',
							close: function (event, ui) {
								if ($('#' + field).attr('value')) {
									$('#' + preview).replaceWith('<img src="' +$('#' + field).attr('value') + '" alt="" id="' + preview + '" class="image" style="width:80px;height:80px" onclick="image_upload(\'' + field + '\', \'' + preview + '\', \'' + id + '\');" />');

								}
							},	
							bgiframe: false,
							width: 700,
							height: 400,
							resizable: false,
							modal: false
						});
					};

//--></script>			
<script type="text/javascript"><!--
$.tabs('#languages a'); 
//--></script>			
			<script type="text/javascript">
function edit_relate(id)
{
	document.getElementById("relate_img_selected").value=id;
}
</script>
